﻿using Consul;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace iS3.Server.Core
{
    public static class ConsulManager
    {
        public static string ip;
        public static string ipInner;
        public static string port;
        public static string serviceName;
        public static string serviceId;
        public static string ocelot;

        public static ConsulClientConfiguration consulConfig;
        static ConsulManager()
        {
            ocelot= ConfigurationManager.AppSettings["OcelotPath"]; 
            ip = ConfigurationManager.AppSettings["WebApiIP"];
            try
            {
                ipInner = ConfigurationManager.AppSettings["WebApiIPInner"];
            }
            catch (Exception ex)
            {
                ipInner = ip;
            }
            if (ipInner == null) ipInner = ip;

            port = ConfigurationManager.AppSettings["WebApiPort"];
            serviceName = ConfigurationManager.AppSettings["ServerID"]; 
            serviceId = serviceName + Guid.NewGuid();
            consulConfig = new ConsulClientConfiguration();
            consulConfig.Address = new Uri(ConfigurationManager.AppSettings["ConsulPath"]);
            consulConfig.Datacenter = ConfigurationManager.AppSettings["ConsulDataCenter"];
        }
    }
}
